package com.atguigu05.api._01optional;

import org.junit.Test;

import java.util.Optional;

/**
 * ClassName: OptionalTest
 * Package: com.atguigu05.api._01optional
 * Description:
 *
 * @Author BuTang
 * @Create 2023/6/25 16:30
 * @Version 1.0
 */
public class OptionalTest {
    @Test
    public void test(){
        String s1 ="无";
        s1  = null;

        Optional<String> opt = Optional.ofNullable(s1);

        String s2 = "z";
        //optional若为空，则会输出orElse中值
        String finals =  opt.orElse(s2);

        System.out.println(finals.toString());
    }
}
